package cn.topevery.garden.dal.logic;

import cn.topevery.garden.dal.dao.BotanyDao;
import cn.topevery.garden.entity.po.Botany;
import cn.topevery.garden.entity.query.BotanyQuery;
import cn.topevery.garden.entity.vo.BotanyVO;
import cn.topevery.garden.framework.base.BaseLogic;
import hw.topevery.framework.db.base.BaseEntityDao;
import hw.topevery.framework.db.entity.DataPager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 
 *
 * @author code-generate
 * @date 2021-08-26
 */
@Service
public class BotanyLogic extends BaseLogic<Botany> {
    @Autowired
    BotanyDao botanyDao;

    @Override
    public BaseEntityDao<Botany, Integer> getDao() {
        return botanyDao;
    }

    

    /**
     * 获取列表
     *
     * @param query
     */
    public DataPager<Botany> listPage(BotanyQuery query) {
        return botanyDao.listPage(query);
    }

    /**
     * 描述 Gets by id.
     *
     * @param id the id
     * @return the by id
     * @author wenzhao.lin
     * @created 2021 -08-25 10:56:00
     */
    public Botany getById(Integer id) {
        Botany entity= botanyDao.getEntity(id);
        return entity;
    }

    /**
     * 根据自增id批量删除
     *
     * @param ids
     */
    public void deleteBatchById(String userId,Integer[] ids) {
        botanyDao.delete(userId, ids);
    }

    /**
     * 根据自增id保存或者更新
     *
     * @param botany 实体
     */
    public boolean saveOrUpdate(String userId, Botany botany){
        botanyDao.saveOrUpdate(userId,botany);
        return true;
    }

    public boolean isExit(String fieldName, String value){
        return botanyDao.isExit(fieldName, value);
    }

    /**
     * 描述 获取实体类.
     *
     * @param p the p
     * @return the botany
     * @author wenzhao.lin
     * @created 2021 -08-26 17:20:07 Get botany botany.
     */
    public Botany getBotany(BotanyVO p){
        Botany tmp = new Botany();

        tmp.setCode(p.getCode());
        tmp.setName(p.getName());
        tmp.setLatinName(p.getLatinName());
        tmp.setDistributionArea(p.getDistributionArea());
        tmp.setTotal(p.getTotal());
        tmp.setMeasure(p.getMeasure());
        tmp.setSection(p.getSection());
        tmp.setGenus(p.getGenus());
        tmp.setHight(p.getHight());
        tmp.setWeight(p.getWeight());
        tmp.setDiameter(p.getDiameter());
        tmp.setSearchStartTime(p.getSearchStartTime());
        tmp.setSearchEndTime(p.getSearchEndTime());
        tmp.setRemark(p.getRemark());

        return tmp;
    }
}
